﻿package view.popup
{
    import com.sh.game.global.*;
    import com.sh.game.util.*;
    import flash.events.*;
    import flash.text.*;
    import flash.utils.*;
    import morn.core.components.*;

    public class NewOpenFuncDialog extends View implements IDialogUI
    {
        protected var uiXML:XML;
        private var text:TextField;
        private var _cfgGuide:Object;
        private var _timeID:uint = 0;

        public function NewOpenFuncDialog()
        {
            this.uiXML = <View>r
n	t	t	t  <Image compId=""2"" url=""png.common.s9_taskbg1"" y=""16"" layer=""1"" width=""170"" height=""80"" sizeGrid=""5,10,5,10"" x=""0""/>r
n	t	t	t  <Image compId=""3"" url=""png.common.newguide"" y=""0"" layer=""1"" x=""26""/>r
n	t	t	t</View>")("<View>
			  <Image compId="2" url="png.common.s9_taskbg1" y="16" layer="1" width="170" height="80" sizeGrid="5,10,5,10" x="0"/>
			  <Image compId="3" url="png.common.newguide" y="0" layer="1" x="26"/>
			</View>;
            return;
        }// end function

        override protected function createChildren() : void
        {
            createView(this.uiXML);
            this.init();
            return;
        }// end function

        public function log(param1:String, param2:int = 0) : void
        {
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            return;
        }// end function

        public function init() : void
        {
            this.visible = false;
            this.x = GlobalLayer.instance.root.stageWidth / 2 - this.width;
            this.y = GlobalLayer.instance.root.stageHeight - 145 - this.height;
            this._cfgGuide = ConfigDictionary.data.guide;
            this.mouseEnabled = false;
            this.addEventListener(MouseEvent.MOUSE_DOWN, this.onDown);
            GlobalLayer.instance.root.addEventListener(Event.RESIZE, this.resizeHandler);
            return;
        }// end function

        public function show(param1:Object) : void
        {
            if (this.text && this.text.parent)
            {
                this.text.parent.removeChild(this.text);
                this.text = null;
            }
            this.text = new TextField();
            this.text.x = 15;
            this.text.y = 45;
            this.text.width = 150;
            this.text.height = 40;
            this.text.defaultTextFormat = new TextFormat("宋体", 12, null, null, null, null, null, null, null, null, null, null, 2);
            this.text.textColor = MColor.New16;
            this.text.autoSize = TextFieldAutoSize.CENTER;
            this.text.wordWrap = true;
            this.text.multiline = true;
            this.text.text = this._cfgGuide[int(param1)].tips;
            this.addChild(this.text);
            this.visible = true;
            if (this._timeID > 0)
            {
                clearTimeout(this._timeID);
                this._timeID = 0;
            }
            this._timeID = setTimeout(this.close, 4000);
            return;
        }// end function

        public function close() : void
        {
            if (this._timeID > 0)
            {
                clearTimeout(this._timeID);
                this._timeID = 0;
            }
            this.visible = false;
            return;
        }// end function

        private function onDown(event:MouseEvent) : void
        {
            event.stopImmediatePropagation();
            return;
        }// end function

        private function resizeHandler(event:Event) : void
        {
            this.x = 210;
            this.y = 230;
            return;
        }// end function

    }
}
